/// @tags: DP
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 5e2 + 5, mod = 1e9 + 7;

int n, m;
char s[maxn], t[maxn];
bool match[maxn];
int f[maxn], g[maxn];

bool check(int index) {
  for (int i = index, j = 1; j <= m; ++i, ++j)
    if (s[i] != t[j]) return false;
  return true;
}

int main() {
  int q;
  cin >> q;
  while (q--) {
    cin >> (s + 1) >> (t + 1);
    n = strlen(s + 1), m = strlen(t + 1);
    memset(f, 0x7f, sizeof(f));
    memset(g, 0, sizeof(g));
    memset(match, 0, sizeof(match));
    for (int i = 1; i + m - 1 <= n; ++i) {
      match[i] = check(i);
    }
    f[1] = 0, g[1] = 1;
    for (int i = 1; i <= n; ++i) {
      if (match[i]) {
        for (int j = i; j; --j) {
          if (i - j >= m && match[j]) break;
          // if (i - j < m) {
          if (f[i + m] > f[j] + 1)
            f[i + m] = f[j] + 1, g[i + m] = g[j];
          else if (f[i + m] == f[j] + 1)
            (g[i + m] += g[j]) %= mod;
          // }
          // if (i - m > 0 && !match[i - m]) {
          // if (f[i + m] > f[j] + 1)
          // f[i + m] = f[j] + 1, g[i + m] = g[j];
          // else if (f[i + m] == f[j] + 1)
          // (g[i + m] += g[j]) %= mod;
          // }
        }
      }
    }
    int last = 0;
    for (int i = n; i; --i) {
      if (match[i]) {
        last = i;
        break;
      }
    }
    int min = 0x7fffffff, cnt = 0;
    for (int i = last + 1; i <= n + 1; ++i) {
      if (min > f[i])
        min = f[i], cnt = g[i];
      else if (min == f[i])
        (cnt += g[i]) %= mod;
    }
    cout << min << ' ' << cnt << endl;
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("CF1729G Cut Substrings.in", "r", stdin);
  freopen("CF1729G Cut Substrings.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
